package info.cs52.fes.action;

import info.cs52.fes.dao.RecipeDAO;
import info.cs52.fes.data.Recipe;
import info.cs52.fes.data.Meal;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class MealUtils {

	public static List<Meal> translate(List<List<String>> mealList) {
		List<Meal> meals = new ArrayList<Meal>();
		for (List<String> recommendedMeal : mealList) {
			Meal meal = new Meal();
			for (String recommendedDish : recommendedMeal) {
				Recipe dish = RecipeDAO.find(recommendedDish);
				if (dish == null) {
					// TODO generate an error instead
					dish = new Recipe(recommendedDish);
				}
				meal.addRecipe(dish);
			}
			meals.add(meal);
		}
		return meals;
	}
		
}
